package com.home.subject;

import com.home.entity.environment.BathEnvironment;
import com.home.entity.environment.Environment;
import com.home.entity.sensor.Sensor;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Администратор
 * Date: 12.05.14
 * Time: 23:52
 * To change this template use File | Settings | File Templates.
 */
public class BathRoomSubject implements Subject {
    private float temp;
    private float humidity;
    //private Environment environment;
    private ArrayList<Sensor> sensors;
    @Override
    public void registerSensor(Sensor sensor) {
        sensors.add(sensor);
    }

    @Override
    public void removeSensor(Sensor sensor) {
        int i = sensors.indexOf(sensor);
        if (i >= 0){
            sensors.remove(i);
        }
    }

    @Override
    public void notifySensor() {
        for (Sensor sensor : sensors){
            sensor.update(new BathEnvironment(temp,humidity));
        }
    }

    public float getTemp() {
        return temp;
    }

    public float getHumidity() {
        return humidity;
    }
}
